# 1.获取训练数据
x,y,idx2label,vocab_size,label_size,idx2word = load_data(file_path,input_shape)
# 2.划分训练、测试数据
x_train, x_test, y_train, y_test =
     train_test_split(x,y,test_size=0.1, random_state=42)
# 3.将numpy转成tensor
x_train = torch.stack(x_train).to(torch.int32)
# torch.stack把[tensor(1),tensor(2)] 转化成 tensor[[tensor(1),tensor(2)]]
y_train = torch.from_numpy(y_train).to(torch.float32)
x_test = torch.stack(x_test).to(torch.int32)
y_test = torch.from_numpy(y_test).to(torch.float32)
# 4.形成训练数据集
train_data = TensorDataset(x_train, y_train)
test_data = TensorDataset(x_test, y_test)
# 5.将数据加载成迭代器
train_loader = torch.utils.data.DataLoader(train_data,batch_size,True)
test_loader = torch.utils.data.DataLoader(test_data,batch_size,False)
